# -*- encoding: utf-8 -*-

class Load (object):

    """ Classe définissant une instruction LOAD Ra Val(Rb). """

    def __init__ (self, ra, val, rb, mem):
        self.__ra = ra 
        self.__val = val
        self.__rb = rb
        self.__mem = mem

    def do (self):
        self.__mem.setRegister(
            num = self.__ra,
            newVal = self.__mem.getRamAt(self.__mem.getRegister(self.__rb) + self.__val)
            )
    
    def __str__ (self):
        return "load r{0:d} {1:d}(r{2:d})".format(self.__ra, self.__val,self.__rb) 

    def __unicode__ (self):
        return self.__str__ () 
